
import router from '/@/router/index'
export type IPermissionType = 'or' | 'and'
export function checkPermission(permission: string | Array<string>, type: IPermissionType = 'or'): boolean {
    const value: Array<string> = typeof permission === 'string' ? [permission] : permission
    const currentRoute = router.currentRoute.value
    const roles:any = currentRoute.meta.permission || []
    if (roles.length == 0) return true   //如果未设置,默认未设置按钮权限 全部显示
    const isShow = type === 'and'
        ? value.every(v => roles.includes(v))
        : value.some(v => roles.includes(v))

    return isShow
}